package com.witmore.skyline.web.controller;

import com.witmore.skyline.web.controller.vo.param.DeviceOilListParamVO;
import com.witmore.skyline.web.controller.vo.result.ResponseResult;
import com.witmore.skyline.web.service.DeviceOilService;
import com.witmore.skyline.web.service.third.yjx.dto.AddOilDTO;
import com.witmore.skyline.web.service.third.yjx.dto.DeviceAvgFuelConsumptionDTO;
import com.witmore.skyline.web.service.third.yjx.dto.DeviceOilConsumptionDTO;
import com.witmore.skyline.web.service.third.yjx.dto.DeviceOilDTO;
import com.witmore.skyline.web.service.third.yjx.dto.DeviceRemainingOilVolumeDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import jakarta.validation.Valid;
import java.util.List;

/**
 * 设备油位接口
 * Author: 豆子高
 * Date: 2025/2/24 14:26
 */
@RestController
@RequestMapping("api/device/oil/")
public class DeviceOilController {
    @Autowired
    private DeviceOilService deviceOilService;

    /**
     * 油位统计接口
     */
    @GetMapping(value = "listOld", name = "油位统计接口")
    public ResponseResult<List<DeviceOilDTO>> oilList(@Valid DeviceOilListParamVO deviceOilListParamVO) {
        return deviceOilService.oilList(deviceOilListParamVO);
    }

    /**
     * 油位统计接口V2（分页优化版，带缓存）
     */
    @GetMapping(value = "list", name = "油位统计接口V2")
    public ResponseResult<List<DeviceOilDTO>> oilListV2(@Valid DeviceOilListParamVO deviceOilListParamVO) {
        return deviceOilService.oilListV2(deviceOilListParamVO);
    }

    /**
     * 加油记录
     */
    @GetMapping(value = "refuelList", name = "加油记录")
    public ResponseResult<AddOilDTO> refuelList(@Valid DeviceOilListParamVO deviceOilListParamVO) {
        return deviceOilService.refuelList(deviceOilListParamVO);
    }

    /**
     * 设备用油量统计
     */
    @GetMapping(value = "oilConsumptionList", name = "设备用油量统计")
    public ResponseResult<List<DeviceOilConsumptionDTO>> oilConsumptionList(@Valid DeviceOilListParamVO deviceOilListParamVO) {
        return deviceOilService.oilConsumptionList(deviceOilListParamVO);
    }

    /**
     * 设备平均油耗统计
     */
    @GetMapping(value = "avgFuelConsumptionList", name = "设备平均油耗统计")
    public ResponseResult<List<DeviceAvgFuelConsumptionDTO>> avgFuelConsumptionList(@Valid DeviceOilListParamVO deviceOilListParamVO) {
        return deviceOilService.avgFuelConsumptionList(deviceOilListParamVO);
    }

    /**
     * 剩余油量统计接口 V2.1
     */
    @GetMapping(value = "remainingOilVolume", name = "剩余油量统计接口")
    public ResponseResult<List<DeviceRemainingOilVolumeDTO>> remainingOilVolumeList(@Valid DeviceOilListParamVO deviceOilListParamVO) {
        return deviceOilService.remainingOilVolumeList(deviceOilListParamVO);
    }
}
